Templates

Templates are displayed via @\template(template_name, arg1, arg2) (args depend on the template)

Also See: AST Templates, Markdown Verbs, Configuration

Docs

  • Create Templates
  • Built-in Templates

Create Templates

  1. Configure your template directories: "dir.templates":['rel/dir1','rel/dir2'] (see Configurations)
  2. Create a .md.php file in your template directory that outputs a string. See Examples.
  3. Code your template.
    • @\template(name, arg1, arg2) will load name.md.php in one of your template dirs.
    • array $args will be passed to the template file.
    • $this refers to the \Tlf\Scrawl instance.

Tip: $scrawl->template_dirs[] = $absolute_path can be used to add additional template directories. Use this if you create an Extension and want to expose template files for others to use.

Note: template_dir/ClassList.md.php is named ClassList, template_dir/php/FunctionList is named php/FunctionList

Built-in Templates

Available Templates: bash/install, git/CloneUrl, git/ChangeLog, all_classes, php/composer_install_inline, php/composer_install

bash/install

Print a short bash script to git clone your repo & create a ~/.bashrc alias pointing to your bin script.

Usage: @\template(bash/install, command_name, rel_bin_path) like @\template(bash/install, scrawl, bin/scrawl)

Output: short bash script in a code block

git/CloneUrl

Print the url used to git clone your repo (always returns HTTPS url)

Usage: @\template(git/CloneUrl)

Output: https://gitlab.com/taeluf/php/CodeScrawl.git (but for your repo)

git/ChangeLog

Print a git log in a markdown list. You can alternatively use @\system(git log ...) command to print it however you'd like.

Usage: @\template(git/ChangeLog)

Output: Same as git log --pretty=format:'- %h %d %s [%cr]' --abbrev-commit

all_classes

Print all classes within the scanned directories

Usage: @\template(all_classes) or echo $scrawl->get_template('all_classes', $array_of_class_asts);

Output: Class list with minimal detail, uses one <h2> for each class.

php/composer_install_inline

Print a composer require statement for the current branch of your repo.

Usage: @\template(php/composer_install_inline, ?composer_package_name, ?branch_name, ?flags), @\template(composer_install), or @\template(composer_install, taeluf/code-scrawl, v0.8.x-dev, --dev). To use defaults, leave the argument blank: @template(php/composer_install_inline,,,--dev)

php/composer_install

Display composer install instructions for the current branch of your repo

Usage: @\template(php/composer_install, ?composer_package_name, ?branch_name), @\template(composer_install), or @\template(composer_install, taeluf/code-scrawl, v0.8.x-dev) (package name and branch name are both optional and typically should be excluded)

Output: a composer require code block and a code block showing what goes in your composer.json